<template>
  <div class="wrap">
    <TreeNode
      :dataAll="datas"
      v-for="item in datas"
      :key="item.id"
      :data="item"
    />
  </div>
</template>

<script>
import TreeNode from "./TreeNode.vue";
export default {
  name: "wrap",
  props: {
    data: Array,
    treeType: String, // default代表默认样式，check代表可选择
  },
  provide() {
    return {
      Tree: this,
    };
  },
  data() {
    return {
      datas: [],
    };
  },
  mounted() {
    this.datas = this.data;

    // console.log(this.datas);
  },
  components: {
    TreeNode,
  },
  computed: {},
  methods: {
    /*
        初始化tree数据
      */
    initData(arr) {
      if (Array.isArray(arr)) {
        arr.forEach((item) => {
//          if (!item.isCheck) {
//            item.isCheck = false;
//          } else {
//            item.isCheck = true;
//          }
          item['_id'] = Math.floor(Math.random() * 1000000000)
          this.initData(item.children);
        });
      }
    },

    fnSetData(arr) {
      this.datas = arr;
    },
  },
  watch: {
  },
};
</script>

<style scoped>
.wrap {
  width: 100%;
  height: auto;
  overflow: hidden;
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  flex-direction: column;
}
</style>
